package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.autoFill.AutoFill;
import com.sky.constant.AutoFillConstant;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * 查询信息
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> page(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 增加菜品分类信息
     * @param category
     */
    @Insert("insert category values(#{id},#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void addCategory(Category category);

    /**
     * 改变分类信息
     * @param category
     */
    @AutoFill(OperationType.UPDATE)
    void change(Category category);

    /**
     * 根据type查询category
     * @param type
     * @return
     */
    @Select("select * from category where type=#{type}")
    List<Category> getByTypeCategory(Integer type);

    /**
     * 根据id删除分类信息
     * @param id
     */
    @Delete("delete from category where id=#{id}")
    void deleteById(Integer id);
}
